<?php
	include_once 'autoload.php';
	

	session_start();

	$ctl = new PicturesCtl();
	$ctl->checkLogged();
	$ctl->proceed();
	
	$form = $ctl->getPicturesForm();
	
	$logged = HtmlUtil::getSessionUser();
	$readonly = $logged->isReadonly();

	$albumId = $form->getAlbumId();
	$albumName = $form->getAlbumName();
	$pictures = $form->getPictures();
	$selected = $form->getSelected();
	
	$header = new Header();
	$header->render('Album: ' . $albumName);

	
	$control = new PictureListControl();
	$rendered = $control->render(4, $pictures, $selected, $readonly);
	
?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="pagename" value="pictures" id="pgid">
<input type="hidden" name="metname" value="" id="metid">
<input type="hidden" name="idedit" value="" id="idedit">

<input type="hidden" name="albumid" value="<?php echo $albumId; ?>">
<input type="hidden" name="albumname" value="<?php echo $albumName; ?>">

<h2>Album: <?php echo htmlspecialchars($albumName); ?> </h2>

<?php echo $rendered; ?>

<table cellspacing="0" cellpadding="8" style="margin-top:10px;">
  <tr>
    <td nowrap>
    <?php
    if($readonly){
    	echo "&nbsp;";
    } 
    else {
    ?>
	    <input type="button" value="Add" onclick="triggerform('add')">
	    <input type="button" value="Multiple" onclick="triggerform('multiple')">
		<input type="button" value="Delete" onclick="triggerform('delete')">
		<input type="button" value="Default" onclick="triggerform('albumDefault')">
	<?php 
    }
    ?>
	</td>
  </tr>
</table>
</form>
<?php
	$footer = new Footer();
	$footer->render();
?>

<script type="text/javascript">
	$('a.lightb').lightBox({
		txtImage: ''
	}); // Select all links in the page
</script>	
